<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <script type="text/javascript" src="js/echarts.js"></script>
    <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="js/jsonTool.js"></script>
</head>
<body style="height: 600px; margin: 0">
<div id="container" style="height: 100%"></div>
<script type="text/javascript">
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};
    option = null;
    myChart.showLoading();
    $.getJSON('data/hecore.json', function (json) {
        myChart.hideLoading();
        console.log(json);
        var graph=json;
        //var graph = echarts.jsonTool.json.parse(json);
        //转换未Links和nodes;
        var categories = [];
	    for (var i = 0; i < 9; i++) {
	        categories[i] = {
	            name: '类目' + i
	        };
	    }
	 	graph.nodes.forEach(function (node) {
	        node.itemStyle = null;
	        node.value = node.symbolSize;
	        node.symbolSize /= 1.5;
	        node.label = {
	            normal: {
	                show: node.symbolSize > 10
	            }
	        };
	        node.category = node.attributes.modularity_class;
	    });
	     option = {
	        title: {
	            text: 'Les Miserables',
	            subtext: 'Circular layout',
	            top: 'bottom',
	            left: 'right'
	        },
	        tooltip: {},
	        legend: [{
	            // selectedMode: 'single',
	            data: categories.map(function (a) {
	                return a.name;
	            })
	        }],
	        animationDurationUpdate: 1500,
	        animationEasingUpdate: 'quinticInOut',
	        series : [
	            {
	                name: 'Les Miserables',
	                type: 'graph',
	                layout: 'circular',
	                circular: {
	                    rotateLabel: true
	                },
	                data: graph.nodes,
	                links: graph.links,
	                categories: categories,
	                roam: true,
	                label: {
	                    normal: {
	                        position: 'right',
	                        formatter: '{b}'
	                    }
	                },
	                lineStyle: {
	                    normal: {
	                        color: 'source',
	                        curveness: 0.3
	                    }
	                }
	            }
	        ]
	    };
	
	    myChart.setOption(option);
	}, 'json');
    if (option && typeof option === "object") {
        var startTime = +new Date();
        myChart.setOption(option, true);
        var endTime = +new Date();
        var updateTime = endTime - startTime;
        console.log("Time used:", updateTime);
    }
</script>
</body>
</html>